package com.otv.model;

import java.io.Serializable;
import java.sql.Blob;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cascade;

@Entity
public class Enseigne implements Serializable {

	private static final long serialVersionUID = 1L;
	private Long id;
	private String nom;
	private Boolean importFileliv;
	private User principalAdminUser;
	private User delegateAdminUser;
	private Language language;
	private FuseauHoraire fuseauHoriare;
	private HashMap<String, String> questionReponses;
	private Set<NiveauNomenclature> lstNiveauNomenclature = new HashSet<NiveauNomenclature>();

	private Blob enseigneLogo;

	public Boolean getImportFileliv() {
		return importFileliv;
	}

	public void setImportFileliv(Boolean importFileliv) {
		this.importFileliv = importFileliv;
	}

	@Lob
	public Blob getEnseigneLogo() {
		return enseigneLogo;
	}

	public void setEnseigneLogo(Blob enseigneLogo) {
		this.enseigneLogo = enseigneLogo;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", unique = false, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	@Override
	public String toString() {
		return "Enseigne [id=" + id + ", nom=" + nom + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((nom == null) ? 0 : nom.hashCode());
		return result;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "enseigne")
	@Cascade({ org.hibernate.annotations.CascadeType.ALL })
	public Set<NiveauNomenclature> getLstNiveauNomenclature() {
		return lstNiveauNomenclature;
	}

	public void setLstNiveauNomenclature(
			Set<NiveauNomenclature> lstNiveauNomenclature) {
		this.lstNiveauNomenclature = lstNiveauNomenclature;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Enseigne other = (Enseigne) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (nom == null) {
			if (other.nom != null)
				return false;
		} else if (!nom.equals(other.nom))
			return false;
		return true;
	}

	@OneToOne(fetch = FetchType.LAZY)
	public User getPrincipalAdminUser() {

		return principalAdminUser;
	}

	public void setPrincipalAdminUser(User principalAdminUser) {
		this.principalAdminUser = principalAdminUser;
	}

	@OneToOne(fetch = FetchType.LAZY)
	public User getDelegateAdminUser() {
		return delegateAdminUser;
	}

	public void setDelegateAdminUser(User delegateAdminUser) {
		this.delegateAdminUser = delegateAdminUser;
	}

	public Language getLanguage() {
		return language;
	}

	public void setLanguage(Language language) {
		this.language = language;
	}

	public HashMap<String, String> getQuestionReponses() {
		return questionReponses;
	}

	public void setQuestionReponses(HashMap<String, String> questionReponses) {
		this.questionReponses = questionReponses;
	}

	public FuseauHoraire getFuseauHoriare() {
		return fuseauHoriare;
	}

	public void setFuseauHoriare(FuseauHoraire fuseauHoriare) {
		this.fuseauHoriare = fuseauHoriare;
	}

}
